package com.zillion.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.zillion.system.domain.vo.HolidayWorkDayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zillion.system.mapper.HealthHolidayMapper;
import com.zillion.system.domain.HealthHoliday;
import com.zillion.system.service.IHealthHolidayService;

/**
 * 法定节假日Service业务层处理
 * 
 * @author zillion
 * @date 2025-10-09
 */
@Service
public class HealthHolidayServiceImpl implements IHealthHolidayService 
{
    @Autowired
    private HealthHolidayMapper healthHolidayMapper;

    /**
     * 查询法定节假日
     * 
     * @param id 法定节假日主键
     * @return 法定节假日
     */
    @Override
    public HealthHoliday selectHealthHolidayById(Long id)
    {
        return healthHolidayMapper.selectHealthHolidayById(id);
    }

    /**
     * 查询法定节假日列表
     * 
     * @param healthHoliday 法定节假日
     * @return 法定节假日
     */
    @Override
    public List<HealthHoliday> selectHealthHolidayList(HealthHoliday healthHoliday)
    {
        return healthHolidayMapper.selectHealthHolidayList(healthHoliday);
    }

    /**
     * 新增法定节假日
     * 
     * @param healthHoliday 法定节假日
     * @return 结果
     */
    @Override
    public int insertHealthHoliday(HealthHoliday healthHoliday)
    {
        return healthHolidayMapper.insertHealthHoliday(healthHoliday);
    }

    /**
     * 修改法定节假日
     * 
     * @param healthHoliday 法定节假日
     * @return 结果
     */
    @Override
    public int updateHealthHoliday(HealthHoliday healthHoliday)
    {
        return healthHolidayMapper.updateHealthHoliday(healthHoliday);
    }

    /**
     * 批量删除法定节假日
     * 
     * @param ids 需要删除的法定节假日主键
     * @return 结果
     */
    @Override
    public int deleteHealthHolidayByIds(Long[] ids)
    {
        return healthHolidayMapper.deleteHealthHolidayByIds(ids);
    }

    /**
     * 删除法定节假日信息
     * 
     * @param id 法定节假日主键
     * @return 结果
     */
    @Override
    public int deleteHealthHolidayById(Long id)
    {
        return healthHolidayMapper.deleteHealthHolidayById(id);
    }

    /**
     * 获取节假日
     */
    @Override
    public ArrayList<String> getHoliday(String year) {
        ArrayList<String> holidays = new ArrayList<>();
        List<HolidayWorkDayVo> holiday = healthHolidayMapper.getHoliday(year);
        for (HolidayWorkDayVo holidayWorkDayVo : holiday) {
            holidays.add(holidayWorkDayVo.getDate());
        }

        return holidays;
    }

    /**
     * 获取节假日补班
     */
    @Override
    public ArrayList<String> getWorkday(String year) {
        ArrayList<String> workdays = new ArrayList<>();
        List<HolidayWorkDayVo> workday = healthHolidayMapper.getWorkday(year);
        for (HolidayWorkDayVo holidayWorkDayVo : workday) {
            workdays.add(holidayWorkDayVo.getDate());
        }
        return workdays;
    }

    @Override
    public List<HealthHoliday> selectHealthHolidayByYear(String year) {
        return healthHolidayMapper.selectHealthHolidayByYear(year);
    }
}
